package j05niming;

class Fa{}
class Ch extends Fa{}

public class J1 {
    public static void main(String[] args) {
        //
        System.out.println(new Ch());
    }
}


abstract class Animal{
    abstract void eat();
    abstract void sleep();
}
class Cat extends Animal{
    @Override
    void eat() {
        System.out.println("猫吃鱼");
    }

    @Override
    void sleep() {

    }
}
class CatTest{
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.eat();
        System.out.println("===简化==");
        //X 匿名局部内部类,,CatTest$1
        Animal animal = new Animal(){
            @Override
            void eat() {
                System.out.println("猫吃鱼2");
            }

            @Override
            void sleep() {

            }
        };
        animal.eat();

        Animal animal2 = new Animal() {
            @Override
            void eat() {

            }

            @Override
            void sleep() {

            }
        };
        animal2.eat();
    }
}


